import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import '../../../../app_files.dart';

class GasAccountInfoModel {
  final String accountID;
  final String userPlatformId;
  final String name;
  final String accountNo;
  final String phone;
  final String address;
  final String idNo;

  final String gasOpenTime;
  final String gasNo;
  final String gasPrice;
  final String gasType;
  final String gasFactory;
  final String communityName;
  final String communityID;

  const GasAccountInfoModel({
    this.accountID,
    this.name,
    this.address,
    this.phone,
    this.accountNo,
    this.gasOpenTime,
    this.gasNo,
    this.gasFactory,
    this.gasPrice,
    this.gasType,
    this.idNo,
    this.userPlatformId,
    this.communityID,
    this.communityName,
  });

  static fromJson(var json) {
    return GasAccountInfoModel(
      name: CommonUtils.checkNullToString(json['UserName']),
      address: CommonUtils.checkNullToString(json['UserAddress']),
      phone: CommonUtils.checkNullToString(json['UserMobile']),
      accountNo: CommonUtils.checkNullToString(json['UserNo']),
      gasOpenTime: CommonUtils.checkNullToString(json['GasUsedTime']),
      gasNo: CommonUtils.checkNullToString(json['GasMeterNo']),
      gasFactory: CommonUtils.checkNullToString(json['MeterFactory']),
      gasType: CommonUtils.checkNullToString(json['GasMeterType']),
      gasPrice: CommonUtils.checkNullToString(json['GasPrice']),
      idNo: CommonUtils.checkNullToString(json['UserIdCard']),
      accountID: CommonUtils.checkNullToString(json['UserId']),
      userPlatformId: CommonUtils.checkNullToString(json['UserPlatformId']),
    );
  }

  static fromWorkJson(var json) {
    return GasAccountInfoModel(
      name: CommonUtils.checkNullToString(json['UserName']),
      address: CommonUtils.checkNullToString(json['UserAddress']),
      phone: CommonUtils.checkNullToString(json['UserMobile']),
      accountNo: CommonUtils.checkNullToString(json['UserNo']),
      gasOpenTime: CommonUtils.checkNullToString(json['GasUsedTime']),
      gasNo: CommonUtils.checkNullToString(json['GasMeterNo']),
      gasFactory: CommonUtils.checkNullToString(json['GasMeterFactory']),
      gasType: CommonUtils.checkNullToString(json['GasMeterType']),
      accountID: CommonUtils.checkNullToString(json['UserId']),
      userPlatformId: CommonUtils.checkNullToString(json['UserPlatformId']),
      communityID:CommonUtils.checkNullToString(json['UserInCommunityId']),
      communityName: CommonUtils.checkNullToString(json['UserInCommunity']),
    );
  }
}

class AccountInfoViewState implements Cloneable<AccountInfoViewState> {
  TextEditingController nameController = TextEditingController(text: '家');
  bool isDel = false;

  String accountNo;
  String accountName;
  String blindID;
  GasAccountInfoModel model;

  @override
  AccountInfoViewState clone() {
    return AccountInfoViewState()
      ..nameController = nameController
      ..isDel = isDel
      ..model = model
      ..accountNo = accountNo
      ..blindID = blindID
      ..accountName;
  }
}

AccountInfoViewState initState(Map<String, dynamic> args) {
  AccountInfoViewState state = AccountInfoViewState();
  if (args != null) {
    state.isDel = args['isDel'] ?? false;
    state.model = args['model'] ?? null;
    state.accountName = args['accountName'] ?? null;
    state.accountNo = args['accountNo'] ?? null;
    state.blindID = args['blindID'] ?? null;
  }
  return state;
}
